package com.yanqu.road.server.cmd.system.cross;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.server.ServerProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = Protocol.S_SYSTEM_LOOP_SYNC_FROM_CROSS, desc = "系统循环同步")
public class CrossSyncSystemLoopCmd implements Command {
	@Override
	public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
		ServerProto.CrossSyncSystemLoopMsg syncMsg = ServerProto.CrossSyncSystemLoopMsg.parseFrom(packet.getBytes());
		GamePlayerMgr.getAllOnlinePlayer().forEach(player -> {
			player.sendPacket(Protocol.U_SYSTEM_LOOP_SYNC, syncMsg.getSyncMsg().toBuilder());
		});

	}
}
